@8btc/office-assistant-mcp 0.0.11 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +45 -46
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -15,8 +15,8 @@ const index_js = require("@modelcontextprotocol/sdk/server/index.js");
|
|
|
15
15
|
const types_js = require("@modelcontextprotocol/sdk/types.js");
|
|
16
16
|
const ReactDOMServer = require("react-dom/server");
|
|
17
17
|
const qrcode_react = require("qrcode.react");
|
|
18
|
-
const winston = require("winston");
|
|
19
18
|
const zod = require("zod");
|
|
19
|
+
const winston = require("winston");
|
|
20
20
|
const zodToJsonSchema$1 = require("zod-to-json-schema");
|
|
21
21
|
const fs = require("fs");
|
|
22
22
|
const fsPromises = require("fs/promises");
|
|
@@ -74950,13 +74950,13 @@ const CodeBlock = ({ inline, className, children, ...props }) => {
|
|
|
74950
74950
|
}
|
|
74951
74951
|
) }) : /* @__PURE__ */ jsxRuntime.jsx("code", { ...props, className, children });
|
|
74952
74952
|
};
|
|
74953
|
-
const imgRegex = /!\[(.*?)\]\((.*?)\)/g;
|
|
74954
|
-
const windowsPattern = /[a-zA-Z]:(?:\\|\/)[^\s"'`<>|?*]*(?:[\\/][^\s"'`<>|?*]*)*/g;
|
|
74955
74953
|
const replaceMarkdown = (mdContent) => {
|
|
74956
|
-
|
|
74957
|
-
|
|
74954
|
+
const imgRegex = /!\[(.*?)\]\((.*?)\)/g;
|
|
74955
|
+
const windowsPattern = /[a-zA-Z]:(?:\\|\/)[^\s"'`<>|?*]*(?:[\\/][^\s"'`<>|?*]*)*/g;
|
|
74956
|
+
return mdContent.replace(imgRegex, (m) => {
|
|
74957
|
+
let match;
|
|
74958
74958
|
let result = "";
|
|
74959
|
-
|
|
74959
|
+
while ((match = imgRegex.exec(m)) !== null) {
|
|
74960
74960
|
const [, alt, src] = match;
|
|
74961
74961
|
if (windowsPattern.test(src)) {
|
|
74962
74962
|
result = `})`;
|
|
@@ -74979,7 +74979,9 @@ const MarkdownRenderer = (props) => {
|
|
|
74979
74979
|
}
|
|
74980
74980
|
]
|
|
74981
74981
|
],
|
|
74982
|
-
components: {
|
|
74982
|
+
components: {
|
|
74983
|
+
code: CodeBlock
|
|
74984
|
+
},
|
|
74983
74985
|
children: replaceMarkdown(markDownContent || "")
|
|
74984
74986
|
}
|
|
74985
74987
|
);
|
|
@@ -74992,7 +74994,7 @@ const Segment = ({ data }) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className
|
|
|
74992
74994
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pdf-columns-2 markdown-body", children: [
|
|
74993
74995
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "lv1Title", children: data.title }),
|
|
74994
74996
|
!!data.content && /* @__PURE__ */ jsxRuntime.jsx(MarkdownRenderer, { markDownContent: data.content }),
|
|
74995
|
-
data.
|
|
74997
|
+
data.childrens?.map((it, idx) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
74996
74998
|
!!it.title && /* @__PURE__ */ jsxRuntime.jsx(Lv2Title, { children: it.title }),
|
|
74997
74999
|
!!it.content && /* @__PURE__ */ jsxRuntime.jsx(MarkdownRenderer, { markDownContent: it.content })
|
|
74998
75000
|
] }, idx))
|
|
@@ -76836,37 +76838,6 @@ const renderFullHtml = (segment) => {
|
|
|
76836
76838
|
`;
|
|
76837
76839
|
};
|
|
76838
76840
|
const getQrcodeUrl = () => process$1.env.QRCODE_URL || "https://reactjs.org/";
|
|
76839
|
-
const logger = winston.createLogger({
|
|
76840
|
-
level: "info",
|
|
76841
|
-
format: winston.format.json(),
|
|
76842
|
-
defaultMeta: { service: "user-service" },
|
|
76843
|
-
transports: [
|
|
76844
|
-
//
|
|
76845
|
-
// - Write all logs with importance level of `error` or higher to `error.log`
|
|
76846
|
-
// (i.e., error, fatal, but not other levels)
|
|
76847
|
-
//
|
|
76848
|
-
new winston.transports.File({
|
|
76849
|
-
dirname: "logs",
|
|
76850
|
-
filename: "office.loggererror.log",
|
|
76851
|
-
level: "error"
|
|
76852
|
-
}),
|
|
76853
|
-
//
|
|
76854
|
-
// - Write all logs with importance level of `info` or higher to `combined.log`
|
|
76855
|
-
// (i.e., fatal, error, warn, and info, but not trace)
|
|
76856
|
-
//
|
|
76857
|
-
new winston.transports.File({
|
|
76858
|
-
dirname: "logs",
|
|
76859
|
-
filename: "office.logercombined.log"
|
|
76860
|
-
})
|
|
76861
|
-
]
|
|
76862
|
-
});
|
|
76863
|
-
if (process.env.NODE_ENV !== "production") {
|
|
76864
|
-
logger.add(
|
|
76865
|
-
new winston.transports.Console({
|
|
76866
|
-
format: winston.format.simple()
|
|
76867
|
-
})
|
|
76868
|
-
);
|
|
76869
|
-
}
|
|
76870
76841
|
async function generateBasePdf(data) {
|
|
76871
76842
|
return [
|
|
76872
76843
|
{
|
|
@@ -76897,7 +76868,6 @@ const renderCover = (data) => {
|
|
|
76897
76868
|
};
|
|
76898
76869
|
const renderSegment = (data) => {
|
|
76899
76870
|
const html2 = ReactDOMServer.renderToString(/* @__PURE__ */ jsxRuntime.jsx(Segment, { data }));
|
|
76900
|
-
logger.error(html2);
|
|
76901
76871
|
return renderFullHtml(html2);
|
|
76902
76872
|
};
|
|
76903
76873
|
const renderEnd = (data) => {
|
|
@@ -76907,7 +76877,7 @@ const renderEnd = (data) => {
|
|
|
76907
76877
|
const paragraph = zod.z.object({
|
|
76908
76878
|
title: zod.z.string().optional().describe("一级标题"),
|
|
76909
76879
|
content: zod.z.string().optional().describe("内容"),
|
|
76910
|
-
|
|
76880
|
+
childrens: zod.z.array(
|
|
76911
76881
|
zod.z.object({
|
|
76912
76882
|
title: zod.z.string().optional().describe("二级标题"),
|
|
76913
76883
|
content: zod.z.string().optional().describe("内容")
|
|
@@ -76923,13 +76893,42 @@ const basePdfSchema = {
|
|
|
76923
76893
|
footer: zod.z.string().describe("报告页脚内容"),
|
|
76924
76894
|
reference: zod.z.string().describe("报告引用"),
|
|
76925
76895
|
paragraph: zod.z.array(paragraph).describe("报告内容"),
|
|
76926
|
-
disclaimer: zod.z.string().optional().describe("ai生成声明")
|
|
76927
|
-
// todo: delete
|
|
76928
|
-
markdown: zod.z.string().optional().describe("markdown")
|
|
76896
|
+
disclaimer: zod.z.string().optional().describe("ai生成声明")
|
|
76929
76897
|
};
|
|
76930
76898
|
zod.z.object({
|
|
76931
76899
|
...basePdfSchema
|
|
76932
76900
|
});
|
|
76901
|
+
const logger = winston.createLogger({
|
|
76902
|
+
level: "info",
|
|
76903
|
+
format: winston.format.json(),
|
|
76904
|
+
defaultMeta: { service: "user-service" },
|
|
76905
|
+
transports: [
|
|
76906
|
+
//
|
|
76907
|
+
// - Write all logs with importance level of `error` or higher to `error.log`
|
|
76908
|
+
// (i.e., error, fatal, but not other levels)
|
|
76909
|
+
//
|
|
76910
|
+
new winston.transports.File({
|
|
76911
|
+
dirname: "logs",
|
|
76912
|
+
filename: "office.loggererror.log",
|
|
76913
|
+
level: "error"
|
|
76914
|
+
}),
|
|
76915
|
+
//
|
|
76916
|
+
// - Write all logs with importance level of `info` or higher to `combined.log`
|
|
76917
|
+
// (i.e., fatal, error, warn, and info, but not trace)
|
|
76918
|
+
//
|
|
76919
|
+
new winston.transports.File({
|
|
76920
|
+
dirname: "logs",
|
|
76921
|
+
filename: "office.logercombined.log"
|
|
76922
|
+
})
|
|
76923
|
+
]
|
|
76924
|
+
});
|
|
76925
|
+
if (process.env.NODE_ENV !== "production") {
|
|
76926
|
+
logger.add(
|
|
76927
|
+
new winston.transports.Console({
|
|
76928
|
+
format: winston.format.simple()
|
|
76929
|
+
})
|
|
76930
|
+
);
|
|
76931
|
+
}
|
|
76933
76932
|
const zodToJsonSchema = (schema) => {
|
|
76934
76933
|
return zodToJsonSchema$1.zodToJsonSchema(zod.z.object(schema), {
|
|
76935
76934
|
rejectedAdditionalProperties: void 0,
|
|
@@ -77033,8 +77032,6 @@ const extractAllImageSrc = (html2) => {
|
|
|
77033
77032
|
}
|
|
77034
77033
|
return srcs;
|
|
77035
77034
|
};
|
|
77036
|
-
const reg = /<img[^>]+>/gi;
|
|
77037
|
-
const regByGroup = /(<img[^>]*?)src=["'][^"']*["']([^>]*>)/gi;
|
|
77038
77035
|
const createPage = async (page, item) => {
|
|
77039
77036
|
const {
|
|
77040
77037
|
tempFileName,
|
|
@@ -77067,11 +77064,13 @@ const createPage = async (page, item) => {
|
|
|
77067
77064
|
})
|
|
77068
77065
|
)
|
|
77069
77066
|
);
|
|
77067
|
+
const reg = /<img[^>]+>/gi;
|
|
77070
77068
|
const _html = html2.replaceAll(reg, (m) => {
|
|
77071
77069
|
const item2 = localFileInfoList.find((info) => {
|
|
77072
77070
|
return m.indexOf(info?.originSrc || "") !== -1;
|
|
77073
77071
|
});
|
|
77074
77072
|
if (item2) {
|
|
77073
|
+
const regByGroup = /(<img[^>]*?)src=["'][^"']*["']([^>]*>)/gi;
|
|
77075
77074
|
return m.replace(regByGroup, `$1src="${item2.base64}"$2`);
|
|
77076
77075
|
}
|
|
77077
77076
|
return m;
|